<!--
 * @Description: 
 * @Date: 2024-01-17 08:53:28
 * @LastEditTime: 2024-02-02 14:21:54
-->
<template>
  <el-dialog
    title="核对"
    :visible.sync="dialogVisible"
    class="qc-config-dialog"
    width="600px"
    :append-to-body="true"
  >
    <el-form
      :model="checkForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="是否重点" prop="chIsImportant">
        <el-radio-group
          v-model="checkForm.chIsImportant"
          placeholder="请输入交办意见"
          clearable
          size="small"
          style="margin-left: 10px"
        >
          <el-radio key="1" label="是" value="1" />
          <el-radio key="0" label="否" value="0" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="督办领导" prop="chUserName">
        <el-input
          v-model="checkForm.chUserName"
          placeholder="请输入测试领导"
        ></el-input>
      </el-form-item>
      <el-form-item label="督办单位" prop="chSuperviseId">
        <el-radio-group v-model="checkForm.chSuperviseId">
          <el-radio
            :label="item.userId"
            v-for="item in userList"
            :key="item.userId"
            >{{ item.userName }}</el-radio
          >
        </el-radio-group>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm"> 核对通过</el-button>
      <el-button @click="dialogVisible = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {
  processInfoProId,
  updateProcessInfo,
  userListByRoleId,
} from "@/api/suggest/index";
export default {
  name: "checkDialog",
  props: ["value", "type", "proId"],
  data() {
    return {
      dialogVisible: false,
      userList: [],
      checkForm: {
        chIsImportant: "",
        chUserName: "",
        chSuperviseId: "",
      },
      rules: {
        chIsImportant: [
          { required: true, message: "请选择是否重点", trigger: "change" },
        ],
        chUserName: [
          { required: true, message: "请输入督办领导", trigger: "blur" },
        ],
        chSuperviseId: [
          { required: true, message: "请选择督办单位", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    userListByRoleId("7").then((res) => {
      this.userList = res.data.users;
    });
  },
  methods: {
    submitForm() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          updateProcessInfo({
            ...this.checkForm,
            status: 1,
            proId: this.proId,
          }).then((res) => {
            this.$message.success("核对成功");

            this.dialogVisible = false;
            this.$parent.getList();
          });
        } else {
          return false;
        }
      });
    },
  },
  watch: {
    value: {
      handler(val) {
        this.dialogVisible = val;
      },
      immediate: true,
    },
    dialogVisible(val) {
      this.$emit("input", val); //关键input
    },
  },
};
</script>

<style lang="scss" scoped></style>
